package com.commAspects.aspects;

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;

import com.commAspects.utils.TimerUtility;

@Aspect
public class ServiceAspects 
{

	@Pointcut("execution(* com.commAspects.aspects.TestServiceAspect.*(..))")
	private void selectAll()
	{
		
	}
	
	@Before("selectAll()")
	public void beforeAdvice(JoinPoint joinPoint)
	{
		System.out.println("Preparing to intercept TestService..."+joinPoint.getSignature().getName());
		TimerUtility.addStart(joinPoint.getSignature().getName(), joinPoint.getSignature().getDeclaringType().toString(), System.currentTimeMillis(), Thread.currentThread().getName());
	}
	
	@After("selectAll()")
	public void afterAdvice(JoinPoint joinPoint)
	{
		System.out.println("Completed intercepting TestService..."+joinPoint.getSignature().getName());
		TimerUtility.addEnd(joinPoint.getSignature().getName(), joinPoint.getSignature().getDeclaringType().toString(), System.currentTimeMillis(), Thread.currentThread().getName());
	}
}
